<template>
  <div class="content-main">
    <!-- 开始问诊治疗展示页面  {{ rotid }}   -->
    <div class="wz-hzxx">
      <div class="w-h-title">
        <div>患者信息</div>
        <div class="w-h-title-right" @click="gotowz">退出问诊 X</div>
      </div>

      <div class="w-h-formtable">
        <el-row :gutter="15" >
          <el-form
            ref="elForm"
            :model="consultation"
            :rules="rules"
            size="medium"
            label-width="100px"
          >
            <el-col :span="5">
              <el-form-item label="就诊编号:">
                <el-input
                  v-model="consultation.registerId"
                  placeholder="请输入就诊id"
                  readonly
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="5">
              <el-form-item label="就诊姓名:">
                <el-input
                  v-model="consultation.register.name"
                  placeholder="请输入就诊姓名"
                  readonly
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="5">
              <el-form-item label="性别:">
                <!-- <el-input v-model="consultation.register.sex" placeholder="请输入民族" readonly :style="{width: '100%'}">
            </el-input> -->
                <dict-tag
                  :options="dict.type.sys_user_sex"
                  :value="consultation.register.sex"
                />
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="手机号:">
                <el-input
                  v-model="consultation.register.phone"
                  placeholder="请输入手机号"
                  readonly
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="年龄:">
                <el-input-number
                  v-model="consultation.register.age"
                  placeholder="年龄"
                  controls-position="right"
                  :disabled="true"
                ></el-input-number>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="民族:">
                <!-- <el-input v-model="consultation.register.nation" placeholder="请输入民族" readonly :style="{width: '100%'}">
            </el-input> -->
                <dict-tag
                  :options="dict.type.people_ethnic_ffiliation"
                  :value="consultation.register.nation"
                />
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="身份证号:">
                <el-input
                  v-model="consultation.register.identityCard"
                  placeholder="请输入身份证号"
                  readonly
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="医保性质:">
                <!-- <el-input v-model="consultation.register.nature" placeholder="请输入医保性质" readonly :style="{width: '100%'}">
            </el-input> -->
                <dict-tag
                  :options="dict.type.patient_medical_status"
                  :value="consultation.register.nature"
                />
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="医保卡号" prop="field105">
                <el-input
                  v-model="consultation.register.cardnumber"
                  placeholder="请输入医保卡号"
                  readonly
                  :style="{ width: '100%' }"
                >
                </el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
    </div>

    <div class="wz-undercontent">
      <div class="wz-wzxx">
        <div class="w-h-title">问诊信息</div>

        <div class="w-w-content">
          <div class="w-w-c-lift">
            <el-row :gutter="15">
              <el-form
                ref="elForm"
                :model="consultationinformationaasd"
                :rules="rules"
                size="medium"
                label-width="100px"
              >
                <el-col :span="20">
                  <el-form-item label="发病日期">
                    <el-date-picker
                      v-model="consultationinformationaasd.time"
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd"
                      :style="{ width: '100%' }"
                      placeholder="还没有数据，请去录入"
                      readonly
                    ></el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="20">
                  <el-form-item label="测量身高">
                    <el-input-number
                      v-model="consultationinformationaasd.height"
                      placeholder="还没有数据，请去录入"
                      controls-position="right"
                      :disabled="true"
                    ></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="20">
                  <el-form-item label="测量体重">
                    <el-input-number
                      v-model="consultationinformationaasd.weight"
                      placeholder="还没有数据，请去录入"
                      controls-position="right"
                      :disabled="true"
                    ></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="20">
                  <el-form-item label="体温">
                    <el-input
                      v-model="consultationinformationaasd.temperature"
                      placeholder="还没有数据，请去录入"
                      readonly
                      :style="{ width: '100%' }"
                    >
                      <template slot="append">°C</template>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="20">
                  <el-form-item label="呼吸">
                    <el-input
                      v-model="consultationinformationaasd.breath"
                      placeholder="还没有数据，请去录入"
                      readonly
                      :style="{ width: '100%' }"
                    >
                      <template slot="append">次/分</template>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="20">
                  <el-form-item label="心率">
                    <el-input
                      v-model="consultationinformationaasd.heartRate"
                      placeholder="还没有数据，请去录入"
                      readonly
                      :style="{ width: '100%' }"
                    >
                      <template slot="append">次/分</template>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="20">
                  <el-form-item label="血压">
                    <el-input
                      v-model="consultationinformationaasd.bloodPressure"
                      placeholder="还没有数据，请去录入"
                      readonly
                      :style="{ width: '100%' }"
                    >
                      <template slot="append">mmHg</template>
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-form>
            </el-row>
          </div>

          <div class="w-w-c-right">
            <el-form
              ref="elForm"
              :model="consultationinformationaasd"
              :rules="rules"
              size="medium"
              label-width="100px"
            >
              <el-form-item label="患者描述">
                <el-input
                  v-model="consultationinformationaasd.patientTalk"
                  type="textarea"
                  placeholder="还没有数据，请去录入"
                  readonly
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
              <el-form-item label="现病史历">
                <el-input
                  v-model="consultationinformationaasd.presentHistory"
                  type="textarea"
                  placeholder="还没有数据，请去录入"
                  readonly
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
              <el-form-item label="既往史历">
                <el-input
                  v-model="consultationinformationaasd.pastHistory"
                  type="textarea"
                  placeholder="还没有数据，请去录入"
                  readonly
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
              <el-form-item label="检查结果">
                <el-input
                  v-model="consultationinformationaasd.inspectionResult"
                  type="textarea"
                  placeholder="还没有数据，请去录入"
                  readonly
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  :style="{ width: '100%' }"
                ></el-input>
              </el-form-item>
            </el-form>
          </div>
        </div>
      </div>

      <div class="wz-mkcz">
        <div class="w-h-title">操作模块</div>
        <div class="w-h-content-czmk">
          <div class="w-m-tjjc" @click="toAddcon">添加问诊信息</div>
          <div class="w-m-tjjc" @click="toexitcon">修改问诊信息</div>
          <div class="w-m-tjjc" @click="toAddche">添加检查项目</div>
          <div class="w-m-tjjc" @click="toAddlookjg">查看检查结果</div>
          <div class="w-m-tjjc" @click="toAddmedic">处方用药</div>
          <div class="w-m-tjjc" @click="toAddzhongzheng">添加重症人员</div>
          <div class="w-m-tjjc" @click="successwz">完成问诊</div>
        </div>
      </div>

      <!-- 添加问诊信息 -->

      <el-dialog
        v-bind="$attrs"
        v-on="$listeners"
        :title="title"
        :visible.sync="dialogaddconsultationinformation"
        @close="cancle"
      >
        <el-form
          ref="elForm"
          :model="consultationinformations"
          :rules="rules"
          size="medium"
          label-width="100px"
        >
          <el-form-item label="日期选择">
            <el-date-picker
              v-model="consultationinformations.time"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              :style="{ width: '100%' }"
              placeholder="请选择日期选择日期选择"
              clearable
             
            ></el-date-picker>
          </el-form-item>

          <el-form-item label="病人姓名">
            <el-select
              v-model="consultationinformations.registerId"
              filterable
              placeholder="请选择病人姓名"
              clearable
              :style="{ width: '100%' }"
            >
              <el-option
                v-for="dict in yuyueList"
                :key="dict.id"
                :label="dict.name + dict.id"
                :value="dict.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="测量身高">
            <el-input-number
              v-model="consultationinformations.height"
              placeholder="测量身高"
              controls-position="right"
            >
            </el-input-number>
          </el-form-item>
          <el-form-item label="测量体重">
            <el-input-number
              v-model="consultationinformations.weight"
              placeholder="测量体重"
              controls-position="right"
            >
            </el-input-number>
          </el-form-item>
          <el-form-item label="体温">
            <el-input
              v-model="consultationinformations.temperature"
              placeholder="请输入体温"
              clearable
              :style="{ width: '100%' }"
            >
              <template slot="append">°C</template>
            </el-input>
          </el-form-item>
          <el-form-item label="呼吸">
            <el-input
              v-model="consultationinformations.breath"
              placeholder="请输入呼吸"
              clearable
              :style="{ width: '100%' }"
            >
              <template slot="append">次/分</template>
            </el-input>
          </el-form-item>
          <el-form-item label="心率">
            <el-input
              v-model="consultationinformations.heartRate"
              placeholder="请输入心率"
              clearable
              :style="{ width: '100%' }"
            >
              <template slot="append">次/分</template>
            </el-input>
          </el-form-item>
          <el-form-item label="mmHg">
            <el-input
              v-model="consultationinformations.bloodPressure"
              placeholder="请输入血压"
              clearable
              :style="{ width: '100%' }"
            >
              <template slot="append">次/分</template>
            </el-input>
          </el-form-item>
          <el-form-item label="患者描述">
            <el-input
              v-model="consultationinformations.patientTalk"
              type="textarea"
              placeholder="请输入患者描述"
              :autosize="{ minRows: 4, maxRows: 4 }"
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
          <el-form-item label="现病史历">
            <el-input
              v-model="consultationinformations.presentHistory"
              type="textarea"
              placeholder="请输入现病史历"
              :autosize="{ minRows: 4, maxRows: 4 }"
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
          <el-form-item label="既往史历">
            <el-input
              v-model="consultationinformations.pastHistory"
              type="textarea"
              placeholder="请输入既往史历"
              :autosize="{ minRows: 4, maxRows: 4 }"
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
          <el-form-item label="检查结果">
            <el-input
              v-model="consultationinformations.inspectionResult"
              type="textarea"
              placeholder="请输入检查结果"
              :autosize="{ minRows: 4, maxRows: 4 }"
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer">
          <el-button @click="cancle">取消</el-button>
          <el-button type="primary" @click="submitForm">确定</el-button>
        </div>
      </el-dialog>

      <!-- 添加检查项目 -->
      <el-dialog
        v-bind="$attrs"
        v-on="$listeners"
        :title="title"
        :visible.sync="dialogaddcherckresult"
        @close="cancle"
      >
        <el-form
          ref="checkresult"
          :model="checkresult"
          :rules="rules"
          size="medium"
          label-width="100px"
        >
          <el-form-item label="选择检查项目" prop="field101">
            <el-select
              v-model="checkresult.checkId"
              filterable
              placeholder="请选择检查项目"
              clearable
              :style="{ width: '100%' }"
            >
              <el-option
                v-for="dict in projectList"
                :key="dict.id"
                :label="dict.name"
                :value="dict.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div slot="footer">
          <el-button @click="cancle">取消</el-button>
          <el-button type="primary" @click="submitcheck">确定</el-button>
        </div>
      </el-dialog>

      <!-- 查看检查结果对话框 -->
      <el-dialog
        v-bind="$attrs"
        v-on="$listeners"
        :title="title"
        :visible.sync="dialoglookcherckresult"
        @close="cancle"
      >
        <el-table :data="lookallresult" style="width: 100%">
          <el-table-column type="expand">
            <template slot-scope="props">
              <el-form label-position="left" inline class="demo-table-expand">
                <el-form-item label="检查名称">
                  <span>{{ props.row.project.name }}</span>
                </el-form-item>
                <el-form-item label="检查结果">
                  <image-preview
                    :src="props.row.img"
                    :width="50"
                    :height="50"
                  />
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column label="检查名称" prop="project.name">
          </el-table-column>
        </el-table>

        <div slot="footer">
          <el-button @click="cancle">取消</el-button>
        </div>
      </el-dialog>

      <!-- 处方用药对话框 -->
      <el-dialog
        v-bind="$attrs"
        v-on="$listeners"
        :title="title"
        :visible.sync="dialogmedicenresult"
        @close="cancle"
      >
        <!-- 搜索区域 -->
        <el-row>
          <el-form :model="queryParams" :inline="true">
            <el-form-item label="处方药">
              <el-input
                v-model="queryParams.name"
                clearable
                placeholder="请输入药名"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="lookmedicen">搜索</el-button>
            </el-form-item>
          </el-form>
        </el-row>

        <!-- 表格区域 -->
        <el-table
          @selection-change="handleSelectionChange"
          :data="medicineList"
          border
          style="width: 100%"
        >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column label="编号" align="center" prop="id" />
          <el-table-column label="名称" align="center" prop="name" />
          <el-table-column label="价格" align="center" prop="price" />
        </el-table>

        <div slot="footer">
          <el-button @click="accessmedicen">确 认</el-button>
          <el-button @click="cancle">取消</el-button>
        </div>
      </el-dialog>

      <!-- 添加重症人员对话框 -->
      <el-dialog
        v-bind="$attrs"
        v-on="$listeners"
        :title="title"
        :visible.sync="dialogaddpatient"
        @close="cancle"
      >
        <el-form
          ref="elForm"
          :model="patientlisted"
          :rules="rules"
          size="medium"
          label-width="100px"
        >
        <el-form-item label="病人姓名" >
          <!-- <el-select v-model="patientlisted.registerId" filterable placeholder="请选择病人姓名" clearable :style="{width: '100%'}">
            <el-option v-for="dict in yuyueList" :key="dict.id" :label="dict.name+dict.id"
              :value="dict.id" >
              </el-option>
          </el-select> -->
          <el-input
                  v-model="consultation.register.name"
                  placeholder="请输入就诊姓名"
                  readonly
                  :style="{ width: '100%' }"
                >
                </el-input>
        </el-form-item>

          <el-form-item label="选择进一步检查项目" prop="field101">
            <el-select
              v-model="patientlisted.projectId"
              filterable
              placeholder="请选择检查项目"
              clearable
              :style="{ width: '100%' }"
            >
              <el-option
                v-for="dict in projectList"
                :key="dict.id"
                :label="dict.name"
                :value="dict.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div slot="footer">
          <el-button @click="cancle">取消</el-button>
          <el-button type="primary" @click="patientsubmit">确定</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import {listConsultation,getConsultation,updateConsultation,} from "@/api/treatment/consultation";
import { listYuyue, getYuyue } from "@/api/register/yuyue";
import {addConsultationinformation, listConsultationinformation,updateConsultationinformation,getConsultationinformationByRegisterId} from "@/api/treatment/consultationinformation";
import { addCost } from "@/api/cost/cost";
import {
  addResult,
  getResult,
  findResultByRegisterIdAndStatus,
} from "@/api/result/result";
import { listProject } from "@/api/treatment/project";
import { addPatientInfo } from "@/api/patient/patientInfo";
import {
  listMedicine,
  getMedicine,
  updateMedicine,
} from "@/api/medicine/medicine";

export default {
  name: "starttreatment",
  dicts: ["sys_user_sex", "people_ethnic_ffiliation", "patient_medical_status"],
  data() {
    return {
  // :picker-options="pickerOptions0"
      // pickerOptions0: {
      //   disabledDate(time) {
      //     return time.getTime() < Date.now() - 8.64e7;//如果没有后面的-8.64e7就是不可以选择今天的
      //   }
      // },
      //传过来的id
      rotid: "",
      regid: "",
      lookaid: "",
      //所有病患列表
      yuyueList: [],
      //所有检查项目
      projectList: [],
      resulted: [],
      //查询所有药物
      medicineList: [],
      //药品总价格
      allmedicenprice: "",

      //查询所有结果
      lookallresult: [],

      //所有问诊信息
      consultationinformationList: [],
      consultationinformation: {
        id: "",
        registerId: "",
        time: "",
        height: "",
        temperature: "",
        breath: "",
        bloodPressure: "",
        weight: "",
        heartRate: "",
        pastHistory: "",
        patientTalk: "",
        presentHistory: "",
        inspectionResult: "",
      },
      consultationinformations: {
        id: "",
        registerId: "",
        time: "",
        height: "",
        temperature: "",
        breath: "",
        bloodPressure: "",
        weight: "",
        heartRate: "",
        pastHistory: "",
        patientTalk: "",
        presentHistory: "",
        inspectionResult: "",
      },
      consultationinformationaasd: {
        id: "",
        registerId: "",
        time: "",
        height: "",
        temperature: "",
        breath: "",
        bloodPressure: "",
        weight: "",
        heartRate: "",
        pastHistory: "",
        patientTalk: "",
        presentHistory: "",
        inspectionResult: "",
      },

      // 问诊对象数据
      consultation: {
        register: {
          name: "",
          sex: "",
          phone: "",
          age: null,
          nation: "",
          identityCard: "",
          nature: "",
          cardnumber: "",
        },
      },

      //检查结果
      checkresult: {
        status: "",
        registerId: "",
        checkId: "",
        money: "",
        cid: "",
      },

      //增加重症
      patientlisted: {
        state: 1,
        registerId: "",
        projectId: "",
      },

      queryParams: {
        name: null,
      },

      //   新增数据类型
      title: "",
      dialogaddconsultationinformation: false,
      dialogaddcherckresult: false,
      dialoglookcherckresult: false,
      dialogmedicenresult: false,
      dialogaddpatient: false,

      // 表单参数
      form: {},
      // 表单校验
      rules: {
        del: [{ required: true, message: "逻辑删除不能为空", trigger: "blur" }],
      },
    };
  },
  methods: {
    //提交表单
    //     submitForm() {
    //   this.$refs['elForm'].validate(valid => {
    //     if (!valid) return
    //     // TODO 提交表单
    //   })
    // },
    // resetForm() {
    //   this.$refs['elForm'].resetFields()
    // },

        /** 查询问诊列表列表 */
        getList() {
      getConsultation(this.rotid).then((response) => {
        this.consultation = response.data;
        this.regid = response.data.registerId;
        this.lookaid=this.regid
        // console.log(this.regid)
        // console.log(response)
        // console.log(this.consultation);


        getConsultationinformationByRegisterId(this.regid).then(response => {
          // console.log(response.data)
          if(response.data!=""&&response.data!=null){
            this.consultationinformation = response.data;
          }
       
      //   console.log( response)
      // console.log(this.consultationinformation)
      this.consultationinformationaasd=this.consultationinformation

      });

      });

      // 查询所有的病患
      listYuyue().then((response) => {
        this.yuyueList = response.rows;
      });

      //查询所有检查项目
      listProject().then((response) => {
        this.projectList = response.rows;
      });

      //通过rid查询信息
      // getTestttl(this.regid).then(response => {
      //   this.consultationinformationList = response.data;
      //   console.log(response)
      // });

/////////////////////////////////////////////////////////////

  //  // 查询所有的问诊信息
  //     listConsultationinformation().then(response => {
  //       this.consultationinformationList = response.rows;
  //       // console.log( response.rows)
  //       // console.log( this.consultationinformationList)
  //       // console.log( this.regid)
  //       for(var i=0;i<this.consultationinformationList.length;i++){
  //         if(this.regid == this.consultationinformationList[i].registerId){
  //     this.consultationinformation.id=this.consultationinformationList[i].id;
  //     this.consultationinformation.registerId=this.consultationinformationList[i].registerId;
  //     this.consultationinformation.time=this.consultationinformationList[i].time;
  //     this.consultationinformation.height=this.consultationinformationList[i].height;
  //     this.consultationinformation.temperature=this.consultationinformationList[i].temperature;
  //     this.consultationinformation.breath=this.consultationinformationList[i].breath;
  //     this.consultationinformation.bloodPressure=this.consultationinformationList[i].bloodPressure;
  //     this.consultationinformation.weight=this.consultationinformationList[i].weight;
  //     this.consultationinformation.heartRate=this.consultationinformationList[i].heartRate;
  //     this.consultationinformation.pastHistory=this.consultationinformationList[i].pastHistory;
  //     this.consultationinformation.patientTalk=this.consultationinformationList[i].patientTalk;
  //     this.consultationinformation.presentHistory=this.consultationinformationList[i].presentHistory;
  //     this.consultationinformation.inspectionResult=this.consultationinformationList[i].inspectionResult

  //         }
	// 		}
  //     console.log(this.consultationinformation)
  //     if(this.consultationinformation!=""){
  //     this.userIsLoggedIn = true;
  //   }

  //     this.consultationinformationaasd=this.consultationinformation
  //     // let aa = this.consultationinformation[this.consultation.registerId]
  //     // console.log(aa)

  //     });

/////////////////////////////////////////////////////

      //查询问诊信息
      // selectrgidConsultationinformation(this.regid).then(response => {
      //   this.consultationinformation = response.data;
      //        console.log(response)
      // });
    },

    //查询所有检查结果
    lookresult() {
      // console.log(this.regid)

      let aa = {
        registerId: this.regid,
      };
      // console.log(aa)
      //查询检查结果
      findResultByRegisterIdAndStatus(aa).then((response) => {
        this.lookallresult = response.data;
        console.log(response);
        // console.log(this.lookallresult)
      });
    },

    //查询所有药品
    lookmedicen() {
      listMedicine(this.queryParams).then((response) => {
        this.medicineList = response.rows;
      });
    },

    //开启新增对话框
    toAddcon() {
      this.title = "新增页面";
      this.dialogaddconsultationinformation = true;
    },

    // 开启新增检查项目对话框
    toAddche() {
      this.title = "新增检查项目";
      this.dialogaddcherckresult = true;
    },

    // 开启查看检查结果对话框
    toAddlookjg() {
      this.title = "查看检查结果";
      this.lookresult();
      this.dialoglookcherckresult = true;
    },

    // 开启处方用药对话框
    toAddmedic() {
      this.title = "处方用药";
      this.dialogmedicenresult = true;
    },

    // 开启添加重症人员对话框
    toAddzhongzheng() {
      this.title = "添加重症人员";
      this.dialogaddpatient = true;
    },

    //开启修改对话框
    toexitcon() {
      this.title = "修改页面";
      this.dialogaddconsultationinformation = true;
      this.consultationinformations = this.consultationinformation;
    },

    /** 提交按钮 */
    //   submitForm() {
    //     if (this.consultationinformation.registerId!=""){
    //       updateConsultationinformation(this.consultationinformations).then(response => {
    //           this.$modal.msgSuccess("修改成功");
    //           this.dialogaddconsultationinformation = false;
    //           this.getList();
    //         });
    //     }else{
    //     addConsultationinformation(this.consultationinformations).then(response => {
    //           this.$modal.msgSuccess("新增成功");
    //           this.dialogaddconsultationinformation = false;
    //           this.getList();
    //         });
    //       }
    // },

    /** 提交按钮 */
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (valid) {
          if (this.consultationinformation.id != "") {
            // console.log(this.consultationinformation.registerId)
            updateConsultationinformation(this.consultationinformations).then(
              (response) => {
                this.$modal.msgSuccess("修改成功");
                this.dialogaddconsultationinformation = false;
                this.getList();
              }
            );
          } else {
            addConsultationinformation(this.consultationinformations).then(
              (response) => {
                this.$modal.msgSuccess("新增成功");
                this.dialogaddconsultationinformation = false;
                this.getList();
              }
            );
          }
        }
      });
    },

    //提交按钮submitcheck
    submitcheck() {
      // console.log(this.checkresult.checkId)

      for (var i = 0; i < this.projectList.length; i++) {
        if (this.checkresult.checkId == this.projectList[i].id) {
          this.resulted.money = this.projectList[i].money;
        }
      }

      let aa = {
        status: 1,
        registerId: this.regid,
        checkId: this.checkresult.checkId,
        money: this.resulted.money,
        cid: "CHECK-" + this.regid,
      };

      console.log(aa);

      addResult(aa).then((response) => {
        this.$modal.msgSuccess("新增成功");
        this.dialogaddcherckresult = false;
        (this.checkresult = {
          status: "",
          registerId: "",
          checkId: "",
          money: "",
          cid: "",
        }),
          this.getList();
      });

      //产生问诊费用（调用cost）
      let cost = {
        costType: 4,
        patientId: this.regid,
        costStatus: 1,
        money: this.resulted.money,
        auditStatus: 1,
        costNum: "COST-" + this.regid,
      };
      addCost(cost).then((response) => {
        this.$modal.msgSuccess("产生问诊费用");
      });

      this.getList();
    },

    //添加重症提交按钮
    patientsubmit() {
      console.log(this.regid)
      this.patientlisted.registerId=this.regid
      addPatientInfo(this.patientlisted).then((response) => {
        this.$modal.msgSuccess("新增成功");
        this.dialogaddpatient = false;
        (this.patientlisted = {
          state: 1,
          registerId: "",
          projectId: "",
        }),
          this.getList();
      });
    },

    //当表格中的行被选中，则会触发的函数
    handleSelectionChange(val) {
      this.shopArray = val;
      console.log("药物信息:" + this.shopArray);
      let aa = 0;
      for (var i = 0; i < this.shopArray.length; i++) {
        // 转换为数字类型，并将结果赋值给变量 price
        let price = Number(this.shopArray[i].price);
        aa += price;

        let bb = {
          id: this.shopArray[i].id,
          num: Number(this.shopArray[i].num) - 1,
        };
        updateMedicine(bb).then((response) => {
          // this.$modal.msgSuccess("修改成功");
        });
      }
      // console.log(aa)
      this.allmedicenprice = aa;
    },

    //确认开药按钮
    accessmedicen() {
      console.log(this.allmedicenprice);

      //产生问诊费用（调用cost）
      let cost = {
        costType: 2,
        patientId: this.regid,
        costStatus: 1,
        money: this.allmedicenprice,
        auditStatus: 1,
        costNum: "COST-" + this.regid,
      };
      addCost(cost).then((response) => {
        this.$modal.msgSuccess("产生问诊费用");
      });

      this.dialogmedicenresult = false;
      this.getList();
      this.lookmedicen();
    },

    /// 取消对话框
    cancle() {
      this.consultationinformations = {
        registerId: "",
        time: "",
        height: "",
        temperature: "",
        breath: "",
        bloodPressure: "",
        weight: "",
        heartRate: "",
        pastHistory: "",
        patientTalk: "",
        presentHistory: "",
        inspectionResult: "",
      };
      //关闭对话框
      this.dialogaddconsultationinformation = false;
      this.dialogaddcherckresult = false;
      this.dialoglookcherckresult = false;
      this.dialogmedicenresult = false;
      this.dialogaddpatient = false;
    },

    //页面跳转

    gotowz() {
      //页面跳转
      this.$router.push({
        path: "/treatment/consultation",
      });
    },

    //完成问诊
    successwz() {
      //拼接对象
      let aa = {
        status: 0,
        id: this.rotid,
      };
      //修改状态值
      updateConsultation(aa).then((response) => {
        this.$modal.msgSuccess("问诊结束成功");
      });

      //产生问诊费用（调用cost）
      let cost = {
        costType: 1,
        patientId: this.regid,
        costStatus: 1,
        money: 100,
        auditStatus: 1,
        costNum: "COST-" + this.regid,
      };
      addCost(cost).then((response) => {
        this.$modal.msgSuccess("产生问诊费用");
      });

      //跳转页面
      this.gotowz();
    },
  },

  created() {
    let id = this.$route.query.id;
    this.rotid = id;
    this.getList();
    this.lookmedicen();
  },
};
</script>

<style>
.content-main {
  margin: 0 auto;
  background-color: #f4f3f3;
  overflow: hidden;
}

.wz-hzxx {
  width: 98%;
  height: 180px;
  background-color: #ffffff;
  margin: 0 auto;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 10px;
}

.w-h-title {
  font-size: 30px;
  margin-top: 10px;
  padding-left: 15px;
  font-family: tutu;
  display: flex;
  justify-content: space-between;
}

.wz-undercontent {
  display: flex;
  justify-content: space-between;
  width: 98%;
  overflow: hidden;
  box-sizing: border-box;
}

.w-h-formtable {
  margin-top: 20px;
  /* display: flex;
   justify-content: space-around; */
  padding-left: 30px;
}

.wz-wzxx {
  width: 78%;
  /* height: 180px; */
  background-color: #ffffff;
  margin: 0 auto;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 10px;
}

.w-w-content {
  margin-top: 10px;
  display: flex;
  justify-content: space-around;
}

.w-w-c-lift {
  width: 40%;
  /* background-color: #e37171; */
}

.w-w-c-right {
  width: 50%;
}

.wz-mkcz {
  width: 20%;
  /* height: 180px; */
  background-color: #ffffff;
  margin: 0 auto;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 10px;
  text-align: center;
}

.w-h-content-czmk {
  margin-top: 10px;
  border-top: 1px solid black;
}

.w-m-tjjc {
  text-align: center;
  background: linear-gradient(to right, #6bd0dd, #77dd9e);
  width: 85%;
  height: 60px;
  font-size: 24px;
  font-family: tutu;
  border-radius: 15px;
  line-height: 55px;
  margin: 0 auto;
  margin-top: 20px;
}

.w-m-tjjc:hover {
  box-shadow: 0px 0px 5px 2px rgb(199, 201, 217);
}

.w-h-tcwz {
  float: right;
}

.w-h-title-right {
  background-color: #f0a1a1;
  color: white;
  font-size: 25px;
  width: 150px;
  border-radius: 10px;
  text-align: center;
  line-height: 35px;
  height: 40px;
  margin-right: 40px;
  font-family: tutu;
}

.w-h-title-right:hover {
  box-shadow: 0px 0px 5px 2px rgb(199, 201, 217);
}

/* 查看结果对话框样式 */
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
/*  */
</style>